-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add more training models and RLHF algorithms #6368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: grpo-latest
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
# [minibatch_size x num_of_generation] | ||
loss_mask = torch.ones(action_mask.size(0), device=action_mask.device).bool() | ||
# [minibatch_size x num_of_generation] | ||
loss_mask = torch.ones(action_mask.size(0), device=action_mask.device).bool() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be better to move the common calculations outside of the if statements for conciseness
# [minibatch_size x num_generations] | ||
advantages = ((reward - reward_mean)).unsqueeze(dim=-1) | ||
|
||
advantages_mean = advantages.mean(dim=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the advantages_mean always 0 as advantage is already zero-centered in the previous step?
advantages_std = advantages.std(dim=0) | ||
|
||
advantages = (advantages - advantages_mean) / (advantages_std + 1e-4) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider double-checking the reinforce++ baseline advantage calculation. In reinforce ++, each sample's advantage is calculated by subtracting the mean reward of all generation in the global batch, not per prompt mean
@@ -0,0 +1,2 @@ | |||
4.51.0: qwen2.5 + grpo, qwen3 + grpo, cannot: llama2, llama3.2 | |||
4.47.0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove test log file
@@ -227,13 +227,13 @@ | |||
os.environ["TOKENIZERS_PARALLELISM"] = "false" # Disable tokenizers parallelism to avoid deadlock | |||
|
|||
inference_model_config = dict(path=args.model) | |||
train_model_config = dict(path=args.model, use_flash_attention_2=True, use_cache=False) | |||
train_model_config = dict(path=args.model, use_flash_attention_2=False, use_cache=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is flash attention not supported?
generate_config = dict(top_k=args.top_k, top_p=args.top_p, temperature=args.temperature) | ||
|
||
if args.backend == "transformers": | ||
inference_model_config.update( | ||
dict( | ||
use_flash_attention_2=True, | ||
use_flash_attention_2=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably also consider force num_generation to 1 for reinforce++
Closes #6367
📌 Checklist before creating the PR
[doc/gemini/tensor/...]: A concise description
pip install pre-commit && pre-commit install
🚨 Issue number
📝 What does this PR do?
Add more training models (LLaMA3, Qwen3) and RLHF algorithms (REINFORCE++, RLOO).
💥 Checklist before requesting a review
⭐️ Do you enjoy contributing to Colossal-AI?
Tell us more if you don't enjoy contributing to Colossal-AI.